package com.pybox.exception;


import com.pybox.dto.Result;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wuyingkai on 2018/9/15.
 */

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler
    @ResponseBody
    public Result<String> exceptionHandler(Exception e) {
        log.error("error message:{}", e.getMessage());
        log.error(e.getMessage(), e);
        return Result.fail(e.getMessage());
    }
}
